<template>
  <div class="app-container">
    <div class="default-box">
      <div class="charges-item">
        <div>积分转赠</div>
        <div>总积分：0.0000</div>
        <div>总手续费：19454.8295</div>
        <div>今日积分：0</div>
        <div>今日手续费：0</div>
      </div>
      <div class="charges-item">
        <div>广告包交易</div>
        <div>总积分：0.0000</div>
        <div>总手续费：19454.8295</div>
        <div>今日积分：0</div>
        <div>今日手续费：0</div>
      </div>
      <div class="charges-item">
        <div>生活缴费</div>
        <div>总积分：0.0000</div>
        <div>总手续费：19454.8295</div>
        <div>今日积分：0</div>
        <div>今日手续费：0</div>
      </div>
      <div class="charges-item">
        <div>转赠退回</div>
        <div>总积分：0.0000</div>
        <div>总手续费：19454.8295</div>
        <div>今日积分：0</div>
        <div>今日手续费：0</div>
      </div>
      <div class="charges-item">
        <div>淘达人分红</div>
        <div>总积分：0.0000</div>
        <div>总手续费：19454.8295</div>
        <div>今日积分：0</div>
        <div>今日手续费：0</div>
      </div>
    </div>
    <div class="default-box">
      <div class="filter-container">
        <el-button class="filter-item" type="primary" icon="el-icon-notebook-2" round plain @click="logDialog = true">
          日志
        </el-button>
      </div>
      <el-table
        :key="tableKey"
        v-loading="listLoading"
        :data="list"
        fit
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="日期">
          <template>
            <span>2023-03-15</span>
          </template>
        </el-table-column>
        <el-table-column label="收入">
          <template>
            <span>0</span>
          </template>
        </el-table-column>
        <el-table-column label="指定支出">
          <template>
            <span>0.0000</span>
          </template>
        </el-table-column>
        <el-table-column label="实际支出">
          <template>
            <span>0</span>
          </template>
        </el-table-column>
        <el-table-column label="当日结余">
          <template>
            <span>
              0
            </span>
          </template>
        </el-table-column>
        <el-table-column label="累计结余">
          <template>
            <span>
              0
            </span>
          </template>
        </el-table-column>
        <el-table-column label="分红时间">
          <template>
            <span>2023-03-15</span>
          </template>
        </el-table-column>
        <el-table-column label="备忘">
          <template>
            <span>备注</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" class-name="small-padding fixed-width">
          <template>
            <el-button type="primary" icon="el-icon-edit" round @click="createDialog=true">
              设置分红
            </el-button>
            <!-- <i class="el-icon-edit" :style="{color:$store.state.settings.theme}" /> -->
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
    <!-- 展示新增、编辑对话框 -->
    <el-dialog
      title="修改"
      :visible.sync="createDialog"
      width="50%"
      custom-class="operate-dialog"
      top="35vh"
      center
    >
      <el-form :model="oprateform" label-width="120px">
        <el-form-item label="今日手续费">
          <el-input v-model="oprateform.name" placeholder="请输入今日后续费" />
        </el-form-item>
        <el-form-item label="备忘">
          <el-input v-model="oprateform.describe" type="textarea" :autosize="{ minRows: 5, maxRows: 5}" placeholder="请输入备忘" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleResetOperate">重置</el-button>
        <el-button type="primary" @click="handleOperate">提交</el-button>
      </span>
    </el-dialog>
    <!--  日志对话框 -->
    <el-dialog
      title="日志"
      :visible.sync="logDialog"
      width="80%"
      custom-class="operate-dialog main-bagcolor"
      top="10vh"
      center
    >
      <ChargeLog />
    </el-dialog>
  </div>
</template>

<script>
import ChargeLog from './components/charge-log'
import { fetchList } from '@/api/article'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
export default {
  name: 'Adminrole',
  components: { Pagination, ChargeLog },
  data() {
    return {
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10,
        title: ''
      },
      status: true,
      createDialog: false, // 是否展示新增、编辑对话框
      logDialog: false, // 是否展示日志对话框
      oprateform: { // 新增、编辑条件
        name: '',
        describe: ''
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },
    // 新增、编辑
    handleOperate() {
      this.createDialog = false
    },
    // 重置新增，编辑内容
    handleResetOperate() {
      this.oprateform = {
        name: '',
        describe: ''
      }
    }
  }
}
</script>
<style scoped lang="scss">
  [class^=el-icon-], [class*=" el-icon-"]{
    font-size: 16px;
  }
  .small-padding i{
    margin-right: 12px;
  }
  .small-padding i:last-child{
    margin-right: 0px;
  }
  .charges-item{
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #191919;
    font-size: 13px;
    border-bottom: 1px solid #F2F3F5;
    text-align: center;
    height: 55px;

    &:last-child{
     border-bottom: none;
    }
    div{
      flex: 1;
    }
  }
</style>
